package com.ugrow.ugrowcommunity.activity.scoreQuery;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import android.app.ActionBar;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.ugrow.ugrowcommunity.R;
import com.ugrow.ugrowcommunity.databinding.ActivityScoreQueryBinding;

public class ScoreQueryActivity extends AppCompatActivity {

    private ActivityScoreQueryBinding binding;
    String[] args = new String[]{"2019-2020-1","2019-2020-2","2020-2021-1","2020-2021-1"};

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityScoreQueryBinding.inflate(getLayoutInflater());
        getWindow().setStatusBarColor(0xffffff);
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        setContentView(binding.getRoot());
        spinnerAdapter();
        addView();
        binding.setBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
    private void spinnerAdapter(){
        ArrayAdapter<String> adapter = new ArrayAdapter<>(ScoreQueryActivity.this, android.R.layout.simple_spinner_item, args);
        binding.scoreTerm.setAdapter(adapter);
    }
    private void addView(){
        for (int i = 0; i < 6; i++) {
            if (i % 2 == 0) {
                View view = LayoutInflater.from(ScoreQueryActivity.this).inflate(R.layout.item_score_grey,null);
                ActionBar.LayoutParams params = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100);
                binding.scoreLiner.addView(view,params);
            }else {
                View view = LayoutInflater.from(ScoreQueryActivity.this).inflate(R.layout.item_score_white,null);
                ActionBar.LayoutParams params = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100);
//                view.setLayoutParams(params);
                binding.scoreLiner.addView(view,params);
            }
        }

    }
}